package com.cupk.controller;

import com.cupk.common.PageResult;
import com.cupk.common.Result;
import com.cupk.dto.BorrowSupplyDto;
import com.cupk.service.BorrowSupplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 名称BorrowSupplyController
 * 描述
 *
 * @version 1.0
 * @author:XiongRuiKai
 * @datatime:2023-06-11 20:31
 */
@RestController
@RequestMapping("/borrow")
public class BorrowSupplyController {
    @Autowired
    private BorrowSupplyService borrowSupplyService;

    /**
     * 分页查询物资申请表
     * @param page 页码
     * @param pageSize 每页返回的数据条目数
     * @param goodsTypeId 物资编号
     * @param departmentContactName 部门联系人
     * @param goodsName 物资名称
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult<BorrowSupplyDto>> getBorrowSuppliesQueryResultsWithPaging(
            @RequestParam(defaultValue = "1") int page,
            @RequestParam(defaultValue = "10") int pageSize,
            @RequestParam(required = false) Integer goodsTypeId,
            @RequestParam(required = false) String departmentContactName,
            @RequestParam(required = false) String goodsName
    ) {
        PageResult<BorrowSupplyDto> pageResult =
                borrowSupplyService.getQueryResultsWithPaging
                        (goodsTypeId,departmentContactName, goodsName,page,pageSize);
        return Result.success(pageResult, "查询成功");
    }
}
